<?php include PATH_VIEWS . 'common/header.php'; ?>
<div class="main">
    <?php include PATH_VIEWS . 'common/left.php'; ?>
    <div class="main_right welcome_right" id="slide">
        <dl>
            <dt><h3>操作说明 <span>[关闭/展开]</span></h3></dt>
            <dd class="border">
                <span>以下红色边框的表单是必填项 。</span>
            </dd>
        </dl>
        <dl>
            <dt class="bottom">
            <h4>多图上传测试</h4>
            </dt>
            <dd>
                <form id="form1" name="form1" method="post" enctype="multipart/form-data" action="<?php echo URL; ?>">
                    <table class="system_envir"> 
                        <tr>
                            <td>图片标题</td>
                            <td class="widt email"><input type="text" name="name" value="<?php echo $edit['Ftitle']; ?>" maxlength="32"/></td>
                            <td>分类名称2-16个字符</td>
                        </tr>
                        <tr>
                            <td>主图</td>
                            <td class="widt"><input type="file" name="img" value="" maxlength="32"/></td>
                            <td>预览：<img src="<?php echo HTTP_UPLOAD . $edit['Fimg']; ?>" width="100"/></td>
                        </tr>
                        <tr>
                            <td>排序</td>
                            <td class="sort"><input type="text"  name="sort" value="1" maxlength="2"/></td>
                            <td id="sort">分类的先后顺序</td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <form method="post" enctype="multipart/form-data" >
                                    <div id="queue"></div>
                                    <input id="file_upload" name="file_upload" type="file" multiple="true">
                                </form>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="subbtn" colspan="2">
                                <a href="index.php?C=Web&A=upload&way=S" class="cancel">返回</a>
                            </td>
                        </tr>
                    </table>
                </form>
            </dd>
        </dl>
    </div>
</div>
<?php include PATH_VIEWS . 'common/footer.php'; ?>
<script type="text/javascript">

    $("#file_upload").uploadify({
        'fileSizeLimit': '3MB',
        'successTimeout': 10,
        'height': 50,
        'width': 200,
        'fileTypeDesc': '上传文件中有不支持的的类型，只能上传图片',
        'fileTypeExts': '*.gif; *.jpg;*.jpeg; *.png; *.bmp',
        'queueSizeLimit': 10,
        'buttonText': '<span class="iconfont" style="font-size:20px;"> 请选择附图</span>',
        'overrideEvents': ['onSelectError', 'onDialogClose'],
        'swf': '<?php echo HTTP_EXTENDS; ?>uploadify/uploadify.swf',
        'uploader': 'index.php?C=Web&A=manyImg&primarykey=<?php echo $pid; ?>',
        'onSelectError': function (file, errorCode, errorMsg) {
            switch (errorCode) {
                case -100:
                    alert("对不起，您一次最多只能上传" + $('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件！");
                    break;
                case -110:
                    alert("文件 [" + file.name + "] 大小超出系统限制的" + $('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小！");
                    break;
                case -120:
                    alert("文件 [" + file.name + "] 大小异常！");
                    break;
                case -130:
                    alert("文件 [" + file.name + "] 类型不正确！");
                    break;
            }
            return false;
        },
        //检测FLASH失败调用
        'onFallback': function () {
            alert("您未安装FLASH控件，无法上传！请安装FLASH控件后再试。");
        },
//            'onUploadStart': function (file) {
//                $('#progress').append('<li>正在上传图片：' + file.name + '</li>');
//            },
//            'onUploadSuccess': function (file, data, response) {
//                upload_num++;
//                $('#progress').append('<li class="color_green">第[' + upload_num + ']张图片：[' + file.name + ']上传成功！</li>');
//            },
        'onUploadError': function (file, errorCode, errorMsg, errorString) {
            $('#progress').append('<li>图片：' + file.name + '不能成功上传</li>');
            //alert(errorCode);
            //alert(errorMsg);
            //alert(errorString);
            alert('上传失败，文件名：' + file.name);
        },
        'onQueueComplete': function (queueData) {
            $('#file_upload-queue').append('<h3 class="color_green" style="text-align:center">您本次一共成功上传了【' + queueData.uploadsSuccessful + '】张图片！</h3>');
            //刷新页面
//            refrashThisPage();
        }
    });

    //上传成功后，定时刷新本页面
//    function refrashThisPage() {
//        setTimeout(, 3000);
//    }
</script>